#ifndef DEVICE_H
#define DEVICE_H

#include <QObject>
#include <QQmlEngine>
#include <QDateTime>
#include <QList>

#include "stdafx.h"
#include "types.h"
#include "result.h"
#include "task.h"

class Device : public QObject
{
    Q_OBJECT

    Q_PROPERTY_READONLY_AUTO(quint8, device_id)
    Q_PROPERTY_READONLY_AUTO(Types::DeviceStatus, device_status)
    // Q_PROPERTY_READONLY_AUTO(QDateTime, last_update_time)
    Q_PROPERTY_READONLY_AUTO(Types::DrivingCurrent, cur_current)
    Q_PROPERTY_READONLY_AUTO(float, cur_voltage)
    Q_PROPERTY_READONLY_AUTO_REF(QList<Result *>, results)
    Q_PROPERTY_READONLY_AUTO(QList<Task *>, tasks)
    Q_PROPERTY_READONLY_AUTO(Types::TaskType, task_type)
    Q_PROPERTY_READONLY_AUTO(quint8, progress)
    Q_PROPERTY_READONLY_AUTO(quint16, freq)

public:
    explicit Device(QObject *parent = nullptr);
    explicit Device(QObject *parent, quint8 id, Types::DeviceStatus status);
    void add_result(Result *result) {
        _results.append(result);
        emit resultsChanged();
    }
    void add_task(Task *task) {
        _tasks.append(task);
        emit tasksChanged();
    }
    Q_INVOKABLE void measure(Types::TaskType type, Types::DrivingCurrent current, quint16 frequency);
signals:
};

#endif // DEVICE_H
